package com.wangge.forkJoin;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Waiter implements Runnable {
  private Calculator cal;

  public Waiter(Calculator cal) {
    this.cal = cal;
  }

  @Override
  public void run() {
    try {
      while (!Thread.interrupted()) {
        synchronized (this) {
          if (cal.i == 0) {
            wait();
          }
        }

        synchronized (this) {
          if (cal.i == 1) {
            System.out.println("启动");
          }
        }
      }

    } catch (InterruptedException e) {
      System.out.println("结束");
    }
  }

}
